﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Bass.Tools;
using MySql.Data.MySqlClient;

public partial class admin_admin_notice_detail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["adminname"]) == "")
        {
            Response.Write("<script language=javascript>alert('您没有登录');window.parent.document.location.href ='admin_login.aspx'</script>");
        }
        else if (Convert.ToString(Session["adminkind"]) != "product")
        {
            Response.Write("<script language=javascript>alert('您不是产品管理员，无权访问此页！');location='admin_login.aspx'</script>");
        }
        if (!IsPostBack)
        {
            //OleDbConnection Conn = new OleDbConnection();
            //Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("../miumiu.mdb");
            //Conn.Open();

            //取到连接字符串
            string propertiesPath = Server.MapPath("../mysqldb.properties");
            mytools mt = new mytools();
            string ConnString = mt.getMysqlConn(propertiesPath);

            //打开连接
            MySqlConnection myConnection = new MySqlConnection(ConnString);
            myConnection.Open();

            MySqlDataAdapter da = new MySqlDataAdapter("select * from notice_info where noticeid='" + Request.QueryString["noticeid"] + "'", myConnection);
            DataSet ds = new DataSet();
            da.Fill(ds,"notice_detail");
            DataRowView rowview = ds.Tables["notice_detail"].DefaultView[0];
            this.noticetitle.Text = rowview["title"].ToString();
            this.noticecontent.Text = rowview["content"].ToString();
            myConnection.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //OleDbConnection Conn = new OleDbConnection();
        //Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("../miumiu.mdb");
        //Conn.Open();

        //取到连接字符串
        string propertiesPath = Server.MapPath("../mysqldb.properties");
        mytools mt = new mytools();
        string ConnString = mt.getMysqlConn(propertiesPath);

        //打开连接
        MySqlConnection myConnection = new MySqlConnection(ConnString);
        myConnection.Open();

        MySqlCommand Comm = new MySqlCommand("update notice_info set title='" + this.noticetitle.Text.ToString() + "',content='" + this.noticecontent.Text.ToString() + "' where noticeid='" + Request.QueryString["noticeid"] + "'", myConnection);
        Comm.ExecuteNonQuery();
        myConnection.Close();
        Response.Write("<script language=javascript>alert('修改成功');</script>");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("admin_notice_list.aspx");
    }
}
